package com.wtwd.device.service;


import com.wtwd.device.model.dto.LocalAppDTO;
import com.wtwd.device.model.entity.AppUser;
import com.wtwd.device.model.entity.AppUserInfo;
import com.wtwd.device.model.entity.HfitAppUser;
import com.wtwd.device.model.vo.ResultVO;

import java.util.Map;

/**
 * <p>
 * 服务类
 * </p>
 *
 * @author zdl
 * @since 2021-08-04
 */
public interface AppUserService {
    /**
     * 保存
     *
     * @param user
     * @return
     */
    boolean save(AppUser user);

    /**
     * 更新
     *
     * @param user
     * @return
     */
    boolean updateById(AppUser user);


    /**
     * 通过手机获取用户嘻嘻
     *
     * @param phone
     * @return
     */
    AppUser getUserByPhone(String phone);

    /**
     * 通过邮箱获取用户
     *
     * @param email
     * @return
     */
    AppUser getUserByEmail(String email);

    /**
     * 根据设备ID更新用户
     *
     * @param user
     * @return
     */
    boolean updateByAppDeviceId(AppUser user);


    /**
     * 通过账号和密码获取用户
     *
     * @param account
     * @param password
     * @return
     */
    AppUser getUserByAccountAndPwd(String account, String password);

    /**
     * @param appDeviceId
     */
    AppUser getUserByAppDeviceId(String appDeviceId);

    /**
     * 发送短信验证码,加区号
     *
     * @param phone
     * @param authType
     * @return
     */
    ResultVO sendSMSAuthCode(String areaCode, String phone, Integer authType);

    /**
     * 发送邮件验证码
     *
     * @param email
     * @param authType
     * @return
     */
    ResultVO sendEmailAuthCode(String email, Integer authType);

    /**
     * 获取当前用户ID
     *
     * @return
     */
    Long getCurrentUserId();

    boolean deleteByAccount(String account, Integer accountType);

    Map<String, Object> getUserInfoByUserId(Long friendId);

    boolean isNotExistAccount(String account, Integer accountType);

    Map<String, Object> getUserInfoByHfitUserId(Long friendId);

    AppUser getUserByUserId(Long userId);

    HfitAppUser getHfitUserByUserId(Long userId);

    boolean deleteById(Long id);

    boolean clearUserData(Long userId);

    void setLocalApp(Long appId);

    LocalAppDTO getLocalApp();

    default AppUserInfo getDefaultObj(Long userId) {
        AppUserInfo appUserInfo = new AppUserInfo();
        appUserInfo.setUserId(userId);
        appUserInfo.setSex("0");
        appUserInfo.setBirthTime("1993");
        appUserInfo.setHeight("170");
        appUserInfo.setWeight("60");
        appUserInfo.setTargetSteps(10000);
        LocalAppDTO localApp = getLocalApp();
        appUserInfo.setName(localApp.getAppName());
        appUserInfo.setUserType(String.valueOf(localApp.getAppId()));
        return  appUserInfo;
    }
}
